import instance from '@/utils/axios.js'

function getChannels() {
    return instance({
        url: "/v1_0/channels",
        method:'get',
    })
}
export { getChannels }
// 获取新闻频道推荐
function getJournalism({channel_id,timestamp}) {
    return instance({
        url: "/v1_0/articles",
        method: 'get',
        params: {
            with_top: 1,
            channel_id,
            timestamp
        }
    })
}
export { getJournalism }
// 文章的详情页
function getdataInfo(id) {
    return instance({
        url: `/v1_0/articles/${id}`,
        method: 'get',
    })
}
export { getdataInfo }
// 取消关注
function removeFollowed(target) {
    return instance({
        url:`/v1_0/user/followings/${target}`,
        method:'delete'
    })
}
// 关注用户
function addFollowed(target) {
    return instance({
        url:`/v1_0/user/followings`,
        method:'post',
        data:{target}
    })
}
export { addFollowed, removeFollowed }

// 点赞
function addLikings(target) {
    return instance({
        url: `/v1_0/article/likings/${target}`,
        method: 'delete',
    })
}
// 取消点赞
function removeLikings(target) {
    return instance({
        url: `/v1_0/article/likings`,
        method: 'post',
        data: {
            target
        }
    })
}
export { addLikings, removeLikings }
// 获取联想建议（自动补全
function suggestion(q) {
    return instance({
        url: `/v1_0/suggestion`,
        method: 'get',
        params: {
            q
        }
    })
}
export { suggestion }

// 喜欢
function addDisLikes(target) {
    return instance({
        url: `/v1_0/article/dislikes`,
        method: 'post',
        data: {
            target
        }
    })
}
// 取消不喜欢
function removeDisLikes(target) {
    return instance({
        url: `/v1_0/article/dislikes/${target}`,
        method: 'delete',
    })
}
export { addDisLikes, removeDisLikes }

// 获取搜索结果
function getSearchList({page,q}) {
    return instance({
        url: `/v1_0/search`,
        method: 'get',
        params: {
            per_page:10,
            page,
            q
            
        }
    })
}


export {getSearchList}